package com.zhangxu.basemvp.base;

import java.lang.ref.WeakReference;

/**
 * Time:2019/4/10
 * Author:zhangxu
 */
public abstract class BasePresenter<V extends BaseView> {

    protected WeakReference<V> mViewRef;

    public void attachView(V view) {
        mViewRef = new WeakReference<>(view);
    }

    public void detachView() {
        if (mViewRef != null) {
            mViewRef.clear();
            mViewRef = null;
        }
    }

    protected V getView() {
        return mViewRef.get();

    }
}
